<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="../../../Themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../../Themes/icon.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/demo.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/common.css">

	</head>

	<body style="padding: 0px;">

		<div class="easyui-layout" style="width:100%;height:500px;">
			<div id="div_search" data-options="region:'north'" style="height: 80px;">

			</div>
			<div data-options="region:'center'">
				<div>
					<table id="tt" class="table_style" style="width: 100%;">
					</table>
				</div>
			</div>
		</div>
		<div id="toolbar"></div>
		<div id="dlg" class="hiddenDialog">
			<iframe id="ifrmEdit" style="width: 100%;height: 100%;" frameborder="0" scrolling="no"></iframe>
		</div>
	</body>
	<script type="text/javascript" src="../../../JS/jquery.min.js"></script>
	<script type="text/javascript" src="../../../JS/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../../../JS/common.js"></script>
	<script type="text/javascript" src="../../../JS/finance.js"></script>
	<script type="text/javascript" src="../../../JS/SHA-1.js"></script>
	<script type="text/javascript" src="../../../JS/LogisticsShareFunction/SearchShareFunction.js"></script>

	<script type="text/javascript">
		//默认查询条件为 STATE为出库完成和DELIVER_COUNT为0
		var _url = RemoteLinkAddress + "/logistics/salesorder/list.do?STATE=出库完成&DELIVER_COUNT=0"; //默认查询链接
		var currSelectData = new Array(); //当前选中的信息数据
		var searchType = SEARCH_CUSTOMER_TYPE + SEARCH_DISTRIBUTION_DATE_START+SEARCH_DISTRIBUTION_DATE_END;
		var content = buildSearchOptions(searchType, "");
		$("#div_search").append(content);
		var data = [{
			"icon": "icon-redo",
			"func": "ProcessOrder()",
			"functionname": "生成配送单明细"
		}];
		_toolbar = AddReceiptsToolBar(0, data);
		$("#toolbar").append(_toolbar);
		getTable();

		function getTable() {
			$('#tt').datagrid({
				url: _url,
				toolbar: '#toolbar',
				method: 'get',
				title: '请勾选单据生成配送单',
				pagination: 'true',
				rownumbers: 'true',
				autoRowHeight: 'true',
				fitColumns: 'false',
				height: 350,
				/*表格中的列名以及各自列名的ID*/
				columns: [
					[{
						field: 'ck',
						checkbox: 'true',
					}, {
						field: 'ID',
						title: '销售单编号',
						width: '18%',
						align: 'center'
					}, {
						field: 'CUSTOMER_TYPE',
						title: '用户组',
						width: '20%',
						align: 'center'
					}, {
						field: 'CUSTOMER_NAME',
						title: '配送单位',
						width: '20',
						align: 'center'
					}, {
						field: 'DISTRIBUTION_DATE',
						title: '配送时间',
						width: '20%',
						align: 'center'
					}, {
						field: 'STATE',
						title: '订单状态',
						width: '20%',
						align: 'center'
					}, ]
				],
			});
		}

		function ProcessOrder() {
			var rowData = $('#tt').datagrid('getSelections');
			if(rowData.length == 0) {
				$.messager.alert("错误", "未能选中需要配送的销售订单");
				return;
			}
			for(var i = 0; i < rowData.length; i++) {
				currSelectData.push(rowData[i]);
			}
			res = JSON.stringify(currSelectData);
			localStorage.setItem('DeliverSelectData', res);
			AddTabIn("创建配送单", parent.$('#tabs'), "UI/LOGISTICS/DeliverManagementCreate/DeliverManagementCreate.html");
		}

		function doSearch() {
			var searchCondition = processSearchCondition();
			_url += "&" + searchCondition; //增加附加的条件
			console.log(_url);
			$('#tt').datagrid('options').url = _url;
			$('#tt').datagrid('reload');
		}
	</script>

</html>